﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace AAA.Forms.Components.Util
{
    public class MdiFormUtil
    {

        private static void MaxChildForm(Form parent, Form form)
        {

            if (form.FormBorderStyle == FormBorderStyle.Sizable)
            {
                Rectangle mdiClientArea = Rectangle.Empty;
                foreach (Control c in parent.Controls)
                    if (c is MdiClient)
                        mdiClientArea = c.ClientRectangle;

                form.Bounds = mdiClientArea;
            }
            form.MdiParent = parent;
        }

        public static void AddChild(Form parent, Form child, bool isMaximizeForm)
        {            
            if(isMaximizeForm)
                MaxChildForm(parent, child);
            child.MdiParent = parent;
            child.Show();

        }
    }
}
